<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php
        //关键字搜索
        require_once('/Users/CTR/desktop/Phpweb1/conn.php'); 
        
        if($_POST['name']){
        //获取文本框的内容
        $keyword=trim($_POST['name']);
       
        }
        
        $query="select * from mytable where name like '%$keyword%'";
        $result=@mysqli_query($conn,$query);
       
        if($result)
        {
             echo '<table align="left" cellspacing="5" cellpading="8">
                     <td align="left" bgcolor=#00FFFF>id</td>
                    <td align="left" bgcolor=#00FFFF>name</td> 
                    <td align="left" bgcolor=#00FFFF>sex</td> 
                    <td align="left" bgcolor=#00FFFF>classnum</td> 
                    <td align="left" bgcolor=#00FFFF>grade</td> 
                    <td align="left" bgcolor=#00FFFF>major</td>
                    </tr>';
 
             while ($row = mysqli_fetch_array($result)) 
        {
             echo '<tr><td align="left">'.
             $row[id].'</td><td align="left">'.
             $row[name].'</td><td align="left">'.
             $row[sex].'</td><td align="left">'.
             $row[classnum].'</td><td align="left">'.
             $row[grade].'</td><td align="left">'.
             $row[major].'</td><td align="left">';        
             echo'</tr>'; 
        }
        echo "</table>"; 
        
        }else{
            
            echo"Failed query";
            echo mysqli_error($conn);
        }    
        mysqli_close($conn);
        include('links.txt');
        ?>
    </body>
</html>
